package com.grao.waterschool.human.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.grao.waterschool.human.common.R;
import com.grao.waterschool.human.entiry.vo.GetVideoRequestBody;
import com.grao.waterschool.human.manager.service.ICCVideoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "根据ChannelCode获取视频流")
@Slf4j
@RestController
@RequestMapping("/getvideo/")
public class ICCVideoController {

    @Autowired
    ICCVideoService iccVideoService;

    @Operation(summary = "根据ChannelCode获取视频流,请求时候请加上SKRQ和SKSJ")
    @SaCheckPermission(orRole = {"super-admin, admin"})
    @PostMapping("rtsp")
    public R<Object> getVideo(@RequestBody GetVideoRequestBody requestBody) throws Exception {
        Integer userId = 18012;
        log.info("--------------requestBody:{}----------------------", requestBody);
        List<String> videoUrl = iccVideoService.getVideoUrl(requestBody, userId);

        log.info("videoUrl:{}", videoUrl);
        return videoUrl != null ? R.success(videoUrl) : R.error("视频流获取失败");
    }
}
